<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Erubis::XmlHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Erubis::XmlHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/erubis/helper_rb.html">
                erubis/helper.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
helper for xml
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000106">escape_xml</a>&nbsp;&nbsp;
      <a href="#M000107">escape_xml2</a>&nbsp;&nbsp;
      <a href="#M000108">h</a>&nbsp;&nbsp;
      <a href="#M000109">html_escape</a>&nbsp;&nbsp;
      <a href="#M000111">u</a>&nbsp;&nbsp;
      <a href="#M000110">url_encode</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">ESCAPE_TABLE</td>
          <td>=</td>
          <td class="context-item-value">{       '&amp;' =&gt; '&amp;amp;',       '&lt;' =&gt; '&amp;lt;',       '&gt;' =&gt; '&amp;gt;',       '&quot;' =&gt; '&amp;quot;',       &quot;'&quot; =&gt; '&amp;#039;',     }</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000106" class="method-detail">
        <a name="M000106"></a>

        <div class="method-heading">
          <a href="#M000106" class="method-signature">
          <span class="method-name">escape_xml</span><span class="method-args">(value)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000106-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000106-source">
<pre>
<span class="ruby-comment cmt"># File erubis/helper.rb, line 24</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_xml</span>(<span class="ruby-identifier">value</span>)
      <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[&amp;&lt;&gt;&quot;]/</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-constant">ESCAPE_TABLE</span>[<span class="ruby-identifier">s</span>] }   <span class="ruby-comment cmt"># or /[&amp;&lt;&gt;&quot;']/</span>
      <span class="ruby-comment cmt">#value.to_s.gsub(/[&amp;&lt;&gt;&quot;]/) { ESCAPE_TABLE[$&amp;] }</span>
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000107" class="method-detail">
        <a name="M000107"></a>

        <div class="method-heading">
          <a href="#M000107" class="method-signature">
          <span class="method-name">escape_xml2</span><span class="method-args">(value)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000107-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000107-source">
<pre>
<span class="ruby-comment cmt"># File erubis/helper.rb, line 29</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_xml2</span>(<span class="ruby-identifier">value</span>)
      <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\&amp;/</span>,<span class="ruby-value str">'&amp;amp;'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/&lt;/</span>,<span class="ruby-value str">'&amp;lt;'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/&gt;/</span>,<span class="ruby-value str">'&amp;gt;'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/&quot;/</span>,<span class="ruby-value str">'&amp;quot;'</span>)
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000108" class="method-detail">
        <a name="M000108"></a>

        <div class="method-heading">
          <span class="method-name">h</span><span class="method-args">(value)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="XmlHelper.html#M000106">escape_xml</a>
</p>
        </div>
      </div>

      <div id="method-M000109" class="method-detail">
        <a name="M000109"></a>

        <div class="method-heading">
          <span class="method-name">html_escape</span><span class="method-args">(value)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="XmlHelper.html#M000106">escape_xml</a>
</p>
        </div>
      </div>

      <div id="method-M000111" class="method-detail">
        <a name="M000111"></a>

        <div class="method-heading">
          <span class="method-name">u</span><span class="method-args">(str)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="XmlHelper.html#M000110">url_encode</a>
</p>
        </div>
      </div>

      <div id="method-M000110" class="method-detail">
        <a name="M000110"></a>

        <div class="method-heading">
          <a href="#M000110" class="method-signature">
          <span class="method-name">url_encode</span><span class="method-args">(str)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000110-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000110-source">
<pre>
<span class="ruby-comment cmt"># File erubis/helper.rb, line 36</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">url_encode</span>(<span class="ruby-identifier">str</span>)
      <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[^-_.a-zA-Z0-9]+/</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">s</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">'C*'</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-value str">&quot;%%%02X&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">i</span> }.<span class="ruby-identifier">join</span>
      }
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>